angular.module('starter.services', [])

  .factory('VersionService', function($http,$q,APPCONSTANT,Base64Service) {
    function checkToken (token,userId){
      var deferred = $q.defer();
      var url = APPCONSTANT.pathUrl + "Token/Request";
      var AuthObj = {
        "code": APPCONSTANT.code,
        "version":APPCONSTANT.version,
        "deviceType": APPCONSTANT.deviceType,
        "token":token
      }
      var Authorization = Base64Service.base64encode(Base64Service.objToString(AuthObj));
      $http.post(url,{
        headers:{'Authorization':Authorization},
        params:{access_token:token,user_id:userId}
      }).success(function (response) {
        //{
        //   "code": "000000",
        //   "message": "验证通过",
        //   "data": {
        //     "content_length": 3,
        //     "access_token": "53d1eda456240b994c047ac9",
        //     "exprires_in": 733222
        //   },
        //   "status": true
        // }
        if(response.code == "000000"){
          deferred.resolve(response.data)
        } else {
          console.log("getToken:"+ response)
        }
      }).error(function (error) {
        console.log("getToken error:"+ error)
      })
      return deferred.promise;
    }
    return {

    };
  })

